-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Remove usages of DataStream#getDefaultBackingIndexName
#129466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
These usages had the potential of causing test failures when a data stream was created before midnight and the backing index name generation ran the next day - which would be millisecconds apart. To avoid these failures, we update the tests to be robust to these time differences. Resolves elastic#123376
|
Pinging @elastic/es-data-management (Team:Data Management) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates test code to remove direct usages of DataStream#getDefaultBackingIndexName in favor of more robust index name resolution methods, reducing the risk of test failures caused by time differences. Key changes include replacing direct calls with projectMetadata.dataStreams() lookups, using DataStreamTestHelper for assertions, and passing explicit time parameters where needed.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/IndicesAndAliasesResolverTests.java | Replaced default backing index name call with data stream lookup |
| x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/TransportPutFollowActionTests.java | Switched to DataStreamTestHelper assertions for backing index names |
| server/src/test/java/org/elasticsearch/cluster/metadata/MetadataTests.java | Updated error messages to use index name from Index object |
| server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDeleteIndexServiceTests.java | Updated index deletion logic with decreased index lookup via data stream |
| server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateDataStreamServiceTests.java | Replaced usages of getDefaultBackingIndexName with write index lookup |
| server/src/test/java/org/elasticsearch/cluster/metadata/DataStreamTests.java | Updated index lookups to use getIndices() calls |
| server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java | Updated test assertions with backing index objects |
| server/src/test/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverServiceTests.java | Injected explicit time parameter to backing index name resolution |
| server/src/test/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverServiceAutoShardingTests.java | Updated source & rollover index name assertions |
| modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/downsampling/DeleteSourceAndAddDownsampleToDSTests.java | Swapped legacy index name calls with data stream index lookups |
| modules/data-streams/src/test/java/org/elasticsearch/datastreams/lifecycle/DataStreamLifecycleServiceTests.java | Replaced legacy index name resolution with DataStreamTestHelper comparisons |
| modules/data-streams/src/test/java/org/elasticsearch/datastreams/MetadataDataStreamRolloverServiceTests.java | Updated rollover tests with explicit time providers and time parameters |
server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDeleteIndexServiceTests.java
Outdated
Show resolved
Hide resolved
…taDeleteIndexServiceTests.java Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One question more than comment but otherwise looks good 👍🏻
| dataStreamName, | ||
| List.of(new Index(DataStream.getDefaultBackingIndexName(dataStreamName, 1, now.toEpochMilli()), "uuid")) | ||
| ).setIndexMode(IndexMode.TIME_SERIES).build(); | ||
| ).setIndexMode(IndexMode.TIME_SERIES).setTimeProvider(now::toEpochMilli).build(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bit of a nitpick not specifically about this PR but I'm interested in why we went for this TimeProvider pattern Vs using the Clock interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm afraid I have no idea... This time provider predates my time at Elastic
These usages had the potential of causing test failures when a data stream was created before midnight and the backing index name generation ran the next day - which would be millisecconds apart. To avoid these failures, we update the tests to be robust to these time differences.
Resolves #123376